<?php namespace App\Exceptions;

use Exception;

class PaymentException extends Exception
{
    const GoodsNotFound                  = 0x01;
    const GoodsStockNotFull              = 0x02;
    const ActivityNotObtained            = 0x03;
    const GoodsSpuNotFound                    = 0x04;
    const ordersNotFound                 = 0x05;
    const UserInfoNotFound               = 0x06;
    const SystemError                    = 0x07;
    const OrdersTypeNotFound             = 0x08;
    const AdmissionRecordNotFound        = 0x09;
    const VipInfoNotFound                = 0x10;
    const VipActivated                   = 0x11;

    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::GoodsNotFound:
                $message = trans('商品已下架');
                break;
            case self::GoodsStockNotFull:
                $message = trans('商品库存不足');
                break;
            case self::ActivityNotObtained:
                $message = trans('活动已下架');
                break;
            case self::GoodsSpuNotFound:
                $message = trans('商品属性不存在');
                break;
            case self::ordersNotFound:
                $message = trans('订单不存在');
                break;
            case self::UserInfoNotFound:
                $message = trans('用户信息不存在');
                break;
            case self::SystemError:
                $message = trans('系统错误');
                break;
            case self::OrdersTypeNotFound:
                $message = trans('订单类型不正确');
                break;
            case self::AdmissionRecordNotFound:
                $message = trans('入会申请的缴费记录不存在');
                break;
            case self::VipInfoNotFound:
                $message = trans('会员信息不存在');
                break;
            case self::VipActivated:
                $message = trans('会员已激活');
                break;
            default:
                $message = trans('未知错误');
                break;
        }

        parent::__construct($message, $code, $previous);
    }

}